package com.test.practice.socket.tcp.file;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @Description: =======================
 * @Author: Jovi
 * =======================
 * @Date: Created in 2023-02-10
 * =======================
 * @Version: 1.1.2.0
 */
public class TcpFileServerDemo {

    public static void main(String[] args) throws Exception {
        ServerSocket ss = new ServerSocket(6666);

        Socket socket = ss.accept();

        InputStream is = socket.getInputStream();

        FileOutputStream fos = new FileOutputStream("5.png");

        byte[] datas = new byte[1024];

        int len;

        while ((len = is.read(datas)) != -1) {
            fos.write(datas, 0, len);
        }
    }
}
